﻿using UnityEngine;

namespace Assets.Common.TextUtils
{
    public static class RichTextUtil
    {
       /// <summary>
       /// 背景底色文字,当不是默认字体时可以在文本背后显示颜色，主要包含透明度
       /// </summary>
       /// <param name="inText"></param>
       /// <param name="markColor"></param>
       /// <returns></returns>
        public static string RichBgMark(string inText, Color markColor)
        {
            return $" <font=\"LiberationSans SDF\"><mark=#{ColorUtility.ToHtmlStringRGBA(markColor)}>{inText}</mark>";
        }
        public static string RichMark(string inText, Color markColor)
        {
            return $"<mark=#{ColorUtility.ToHtmlStringRGBA(markColor)}>{inText}</mark>";
        }
        public static string RichColor(string inText, Color color)
        {
            return $"<color=#{ColorUtility.ToHtmlStringRGBA(color)}>{inText}</color>";
        }
        public static string RichSize(string inText, float size)
        {
            return $"<size={size}>{inText}</size>";
        }
        public static string RichSprite(string atlasName, string name, Color color)
        {
            return $"<sprite=\"{atlasName}\" name={name} color=#{ColorUtility.ToHtmlStringRGBA(color)}>";
        }
        public static string RichSprite(string atlasName, int index, Color color)
        {
            return $"<sprite=\"{atlasName}\" index={index} color=#{ColorUtility.ToHtmlStringRGBA(color)}>";
        }

        /// <summary>
        /// 给内容增加ink标签
        /// </summary>
        public static string AddLinkeTag(string id, string data)
        {
            return $"<link=\"{id}\"><color=\"yellow\">{data}</color></link>";
        }
    }
}